import { Injectable } from '@angular/core';
import * as gc from 'src/app/global/const';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { SysuserService } from './sysuser.service';

@Injectable({
  providedIn: 'root'
})
export class AuthService {

  isLoggedIn = true;
  redirectUrl: string;

  url = {
    'login':gc.BACKEND_SERVER_ROOT + '/login/in',// post
    'logout':gc.BACKEND_SERVER_ROOT + '/login'// get
  }

  constructor(
    private http:HttpClient
  ) { }

  login(loginUser:SysUser):Observable<any>{
    return this.http.post<any>(this.url.login,loginUser);
  }

  logout(){
    this.isLoggedIn = false;
  }
}

// Author：chanchaw
// Generator Version：1.0 - 2019年11月16日 16点46分
// This Model Created：Mon Dec 09 2019 13:25:25 GMT+0800 (中国标准时间)
export class SysUser{
  create_time:Date;
  iid:number;
  last_time:Date;
  non_expired:boolean;
  non_locked:boolean;
  non_password_expired:boolean;
  password:string;
  remark:string;
  status:number;
  userid:string;
  username:string;
}

export class UserFuse{
  user:SysUser = new SysUser();
  authorities:string[] = [];

  constructor(){
    this.user = new SysUser();
    this.authorities = [];
  }
}


